<!--
 * @Descripttion:未开设专户项目
 * @version:
 * @Author: zhangfan
 * @email: 2207044692@qq.com
 * @Date: 2020-06-03 14:02:12
 * @LastEditors: younghxp
 * @LastEditTime: 2022-02-15 10:07:16
-->
<template>
  <div class="container" ref="mainCon">
    <topTitle :titleText="titleText"></topTitle>
    <div class="mainCon">
      <el-row class="toolbar searchInputWidth" style="padding-bottom: 0">
        <el-form :inline="true" :model="filterField" ref="searchConditions">
          <el-col :lg="8" :xl="6">
            <el-form-item label="项目名称" class="row-padding-bottom">
              <el-input
                v-model="filterField.projectName"
                placeholder="请输入项目名称"
                clearable
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :lg="8" :xl="6">
            <el-form-item label="区域" class="row-padding-bottom">
              <el-cascader
                ref="manageArea"
                v-model="areaId"
                :options="areasOptions"
                @change="getAreaId"
                height="250"
                clearable
                filterable
                :props="{ checkStrictly: true }"
              ></el-cascader>
            </el-form-item>
          </el-col>
          <template v-if="advanced">
            <el-col :lg="8" :xl="6">
              <el-form-item label="行业" class="row-padding-bottom">
                <el-select
                  v-model="filterField.industryId"
                  filterable
                  placeholder="请选择"
                  clearable
                >
                  <el-option
                    v-for="item in industryOptions"
                    :key="item.code"
                    :label="item.name"
                    :value="item.code"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :lg="8" :xl="6">
              <el-form-item label="状态" class="row-padding-bottom">
                <el-select
                  v-model="filterField.status"
                  filterable
                  placeholder="请选择"
                  clearable
                >
                  <el-option
                    v-for="item in statusOptions"
                    :key="item.id"
                    :label="item.name"
                    :value="item.id"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :lg="8" :xl="6">
              <el-form-item label="施工方" class="row-padding-bottom">
                <el-input
                  v-model="filterField.pbName"
                  placeholder="请输入施工方"
                  clearable
                ></el-input>
              </el-form-item>
            </el-col>
          </template>
          <el-col :lg="8" :xl="6">
            <el-form-item label="">
              <a
                @click="toggleAdvanced"
                style="margin-left: 40px; color: #409eff; cursor: pointer"
                class="btnColor"
              >
                {{ advanced ? '收起' : '展开' }}
                <i
                  :class="advanced ? 'el-icon-arrow-up' : 'el-icon-arrow-down'"
                ></i>
              </a>
              <el-button
                type="primary"
                icon="icon iconfont iconchazhao1"
                @click="searchList"
                class="searchBtn"
              >
                <span>搜索</span>
              </el-button>
              <el-button
                @click="exportExcel"
                class="commonBut saveBtn funComBut"
                icon="icon iconfont icondaochu"
                v-show="exportBtn"
                ><span class="opetareText">导出</span></el-button
              >
            </el-form-item>
          </el-col>
          <!-- <el-form-item>
            <el-button
              @click="exportExcel"
              class="commonBut saveBtn funComBut"
              icon="icon iconfont icondaochu"
              v-show="exportBtn"
            >导出</el-button>
          </el-form-item> -->
        </el-form>
      </el-row>
      <div class="spacing"></div>
      <div
        ref="tableBox"
        :class="hiddleToolBar ? 'tableBoxCur tableBox' : 'tableBoxCur'"
      >
        <el-table
          ref="tableBox1"
          :max-height="tableHeight"
          :data="tableList"
          v-loading="loading"
          :header-cell-style="{ background: '#eef1f6', color: '#606266' }"
          highlight-current-row
          stripe
          style="border: 1px solid #dfe6ec"
          :default-sort="{ prop: 'date', order: 'descending' }"
          @sort-change="sortChange"
        >
          <!-- <el-table-column prop="projectName" label="项目名称"></el-table-column> -->
          <el-table-column label="项目名称" width="230">
            <template slot-scope="scope">
              <copyText
                :tableIndex="scope.$index"
                :copyTextName="scope.row.projectName"
                :columnName="'projectName'"
              ></copyText>
            </template>
          </el-table-column>
          <el-table-column
            prop="areaName"
            label="区域"
            align="center"
            :formatter="formatTd"
            min-width="120"
          ></el-table-column>
          <el-table-column
            prop="industryName"
            label="行业"
            align="center"
            :formatter="formatTd"
            min-width="120"
          ></el-table-column>
          <el-table-column
            prop="statusDesc"
            label="状态"
            align="center"
            :formatter="formatTd"
            width="120"
          ></el-table-column>
          <!-- <el-table-column prop="pbName" label="施工方" align="center" :formatter="formatTd"></el-table-column> -->
          <el-table-column label="施工方" width="230">
            <template slot-scope="scope">
              <copyText
                :tableIndex="scope.$index"
                :copyTextName="scope.row.pbName"
                :columnName="'pbName'"
              ></copyText>
            </template>
          </el-table-column>
          <el-table-column
            prop="total"
            sortable="custom"
            label="工程造价(万元)"
            align="center"
            :formatter="dateForma"
            min-width="160"
          ></el-table-column>
          <el-table-column
            prop="leader"
            label="项目负责人"
            align="center"
            :formatter="formatTd"
            min-width="120"
          ></el-table-column>
          <el-table-column
            prop="leaderTel"
            label="负责人联系方式"
            align="center"
            min-width="160"
          >
            <template slot="header">
              <span>负责人联系方式</span>
              <span
                class="icon iconfont"
                @click="isShowTel = !isShowTel"
                :class="isShowTel == true ? 'iconxianshi' : 'iconyincang'"
              ></span>
            </template>
            <template slot-scope="scope">
              <p v-if="scope.row.leaderTel && !isShowTel">
                {{ scope.row.leaderTel | deseHandler(4, 4, '*') || '' }}
              </p>
              <p v-if="scope.row.leaderTel && isShowTel">
                {{ scope.row.leaderTel }}
              </p>
              <p v-if="!scope.row.leaderTel">未填写</p>
            </template>
          </el-table-column>
          <!-- 表格数据为空时，页面显示 -->
          <div slot="empty" v-show="isShow">
            <emptyTable emptyText="暂无相关信息"></emptyTable>
          </div>
        </el-table>
        <!-- filterField为搜索条件 -->
        <!-- getTableList为获取子组件的数据 -->
        <Pagination
          ref="pagination"
          @getList="getTableList"
          :filterField="filterField"
          :requestUrl="requestUrl"
        ></Pagination>
      </div>
    </div>
  </div>
</template>
<script>
import scrollTable from '@/mixin/scrollTable.js'
import { mapState, mapActions } from 'vuex'
import common from '../../kits/common'
export default {
  name: 'projectwithoutaccount',
  mixins: [scrollTable],
  data() {
    return {
      textarea: '',
      bankOptions: [],
      isShowTel: false,
      canLogin: false, //专户保存按钮loading
      areasOptions: [], //区域
      titleText: '未开设专户项目',
      advanced: false,
      //表格数据
      tableList: [],
      requestUrl: 'api-p/project/expand/projectwithoutaccount',
      areaId: '', //区域
      //搜索条件
      filterField: {
        projectName: '', //项目名称
        areaId: '', //区域
        status: '', //开工状态
        industryId: '', //行业
        investment: '', //投资类型
        pbName: '', //施工方
      },
      isShow: false, //列表加载
      loading: true,
      exportBtn: '',
    }
  },
  created() {
    this.getInvestmenttype({})
    this.getStatus({})
    this.getIndustry({})
    //获取区域
    this.getAreas()
    this.$nextTick(function () {
      this.$refs.pagination.getTableListData()
    })
    this.exportBtn =
      this.$store.state.buttonLimitsArr.indexOf('bankwithoutaccount:export') >
      -1
  },
  computed: {
    ...mapState(['investmentOptions', 'statusOptions', 'industryOptions']),
  },
  methods: {
    toggleAdvanced() {
      this.advanced = !this.advanced
    },
    ...mapActions(['getInvestmenttype', 'getStatus', 'getIndustry']),
    //导出筛选条件下列表所有未开设专户数据
    exportExcel() {
      window.location.href =
        common.commonApi +
        'api-p/project/expand/expprojectwithoutaccount?projectName=' +
        encodeURIComponent(this.filterField.projectName) +
        '&areaId=' +
        this.filterField.areaId +
        '&status=' +
        this.filterField.status +
        '&industryId=' +
        this.filterField.industryId +
        '&investment=' +
        this.filterField.investment +
        '&sortField=' +
        this.filterField.sortField +
        '&sort=' +
        this.filterField.sort +
        '&access_token=' +
        localStorage.getItem('access_token')
    },
    getAreas() {
      this.axios({
        method: 'post',
        url: 'api-bs/areadic/base/areacombobox',
        data: {
          areaId: this.$store.state.areaInfoArr.areaId,
        },
      })
        .then((res) => {
          this.areasOptions = res.data.result
        })
        .catch((error) => {
          this.$message({
            showClose: true,
            duration: 3000,
            message: '获取区域数据失败',
            type: 'error',
          })
        })
    },
    //获取选中的区域最后一级id
    getAreaId() {
      var areaId = this.areaId[this.areaId.length - 1]
      this.filterField.areaId = areaId
    },
    getTableList(data) {
      this.tableList = data
      this.loading = false
      if (this.tableList.length < 1) {
        this.isShow = true
      }
    },
    // 搜索
    searchList() {
      this.$refs.pagination.getTableListData()
    },
    dateForma(row, column) {
      const daterc = row[column.property]
      if (daterc) {
        let lately2 = daterc.toFixed(3) //对小数点后3位四舍五入
        return lately2.substring(0, lately2.lastIndexOf('.') + 3)
      } else {
        return '--'
      }
    },
  },
}
</script>

<style scoped lang="less">
.addFinancial {
  margin-bottom: 24px;
  float: right;
}
/deep/ .el-input-number .el-input__inner {
  text-align: left;
}
.mainCon {
  top: 198px;
}
@import '../../../static/css/filterArea.less';
</style>
